package vn.sunnet.game.SinhTon.map;

import java.util.ArrayList;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;

// Class doc file chua so quai cua tung map
public class InfoMap {
	private int map;
	// Luu so quai vao moi chang, co 6 chặng
	private ArrayList<Integer> stage1;
	private ArrayList<Integer> stage2;
	private ArrayList<Integer> stage3;
	private ArrayList<Integer> stage4;
	private ArrayList<Integer> stage5;
	private ArrayList<Integer> stage6;

	public InfoMap(int map) {
		this.map = map;
		stage1 = new ArrayList<Integer>();
		stage2 = new ArrayList<Integer>();
		stage3 = new ArrayList<Integer>();
		stage4 = new ArrayList<Integer>();
		stage5 = new ArrayList<Integer>();
		stage6 = new ArrayList<Integer>();
		showResult();
	}

	public ArrayList<Integer> getStage(int numberStage) {
		switch (numberStage) {
		case 1:
			return stage1;
		case 2:
			return stage2;
		case 3:
			return stage3;
		case 4:
			return stage4;
		case 5:
			return stage5;
		case 6:
			return stage6;
		}
		return null;
	}

	public void showResult() {
		// Doc file data
		FileHandle file = Gdx.files.internal("data\\gameData\\map"
				+ String.valueOf(map) + ".data");
		String text = file.readString();

		String newText = text.replace("\n", "");
		String[] texts = newText.split(" ");
		// Gdx.app.error("number", String.valueOf(texts.length));

		ArrayList<Integer> data = new ArrayList<Integer>();
		for (int i = 0; i < 66; i++) {
			data.add(Integer.parseInt(texts[i].trim()));
			// Gdx.app.error(getClass().toString(), data.get(i) +
			// " size data i");
		}
//		Gdx.app.error(getClass().toString(), data.size() + " size data");
		for (int i = 0; i < data.size(); i++) {
			if (i < 11) {
				stage1.add(data.get(i));
			} else if (i < 22) {
				stage2.add(data.get(i));
			} else if (i < 33) {
				stage3.add(data.get(i));
			} else if (i < 44) {
				stage4.add(data.get(i));
			} else if (i < 55) {
				stage5.add(data.get(i));
			} else
				stage6.add(data.get(i));
		}
	}

}
